package code.tools.gameIni
{
	import code.main.AppData;
	import code.untils.GameConst;
	
	import flash.utils.Dictionary;

	/**
	 *配置信息数据 
	 * @author Yuri
	 * 
	 */
	public class GameIniData
	{
		
		/**
		 *配置文件路径 
		 */
		public static var gameIniPath:String = "gameIni.xml";
		
		/**
		 *主体swf路径 
		 */
		public static var mainPath:String = "";
		
		/**
		 *图片加载地址 
		 */
		public static var gameImagePath:String = AppData.fileUrl+"files/image/"
		
		/**
		 *版本号 （暂时没用） 
		 */
		public static var version:String;
		/**
		 *loading 
		 */
		public static var loadingItem:LoadItem;
		/**
		 *首次加载列表 
		 */
		private static var firstLoadItemList:Array = [];
		/**
		 *第二层加载列表 
		 */
		public static var secondLoadItemList:Array = [];
		/**
		 *新手引导列表 
		 */
		public static var newHandLoadItemList:Array = [];
		
		public static var uiDic:Dictionary = new Dictionary();
		public function GameIniData()
		{
		}
		
		/**
		 *分析 配置信息 
		 * @param dXml
		 * 
		 */
		public static function analysisGameXml(dXml:XML):void{
			version = dXml.version.toString();
			GameConst.isTraceLogByTool = int(dXml.tracetoollog)==1;
			var listCount:int = dXml.list.length();
			var loadCount:int;
			var i:int = 0;
			var j:int;
			for(i=0;i<listCount;i++){
				var listXml:XML = dXml.list[i] as XML;
				loadCount = listXml.loadpath.length();
				var loadItem:LoadItem;
				var type:int = int(listXml.@type);
				for(j=0;j<loadCount;j++){
					loadItem = LoadItem.parserData(XMLList(listXml.loadpath[j]));
					if(loadItem.lang == "all" || loadItem.lang == AppData.language){
						if(loadItem.name == "loading"){
							loadingItem = loadItem;
							continue;
						}
						if(type == 0){
							firstLoadItemList.push(loadItem);
						}else if(type == 1){
							secondLoadItemList.push(loadItem);
						}else if(type == 2){
							newHandLoadItemList.push(loadItem);
						}
						uiDic[loadItem.name] = loadItem;
					}
				}
			}
		}
		
		/**
		 * 获取首次加载列表 
		 * @param isNeedNewHand
		 * @return 
		 * 
		 */
		public static function getFirstLoadItemList(isNeedNewHand:Boolean = true):Array{
			return isNeedNewHand?firstLoadItemList.concat(newHandLoadItemList):firstLoadItemList;
		}
	}
}